home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / graphics.17 / graphics / graphics-0.17 / plot2fig / fontname.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-12  |  2.0 KB  |  79 lines

  1. /* plot, unix plot file to graphics device translators.
  2.    Copyright (C) 1989 Free Software Foundation, Inc.
  3.  
  4.    plot is distributed in the hope that it will be useful, but WITHOUT
  5.    ANY WARRANTY.  No author or distributor accepts responsibility to
  6.    anyone for the consequences of using it or for whether it serves any
  7.    particular purpose or works at all, unless he says so in writing.
  8.    Refer to the GNU General Public License for full details.
  9.    
  10.    Everyone is granted permission to copy, modify and redistribute plot,
  11.    but only under the conditions described in the GNU General Public
  12.    License.  A copy of this license is supposed to have been given to you
  13.    along with plot so you can know your rights and responsibilities.  It
  14.    should be in a file named COPYING.  Among other things, the copyright
  15.    notice and this notice must be preserved on all copies.  */
  16.  
  17.  
  18. /* FONTNAME takes a string argument S containing the name of the
  19.    desired current font and sets the current font to that name. */
  20.  
  21. #include "sys-defines.h"
  22. #include "libplot.h"
  23. #include "extern.h"
  24.  
  25. /* a simple fixed string matcher. match returns
  26.    1 if there is a match for s1 in s2, else 0. */
  27. int
  28. match (s1, s2)
  29.      char *s1, *s2;
  30. {
  31.   int len2, i;
  32.   len2 = strlen (s2);
  33.  
  34.   for (i=0; i<len2; i++)
  35.     {
  36.       if (strcmp (s1, &s2[i]) == 0)
  37.     {
  38.       return 1;
  39.     }
  40.     }
  41.   return 0;
  42. }
  43.  
  44. int font_id = 0; /* the default font */
  45.  
  46. int
  47. fontname (s)
  48.     char *s;
  49. {
  50.   char *res;
  51.  
  52.   res = (char *) re_comp (s);
  53.   if (res)
  54.     {
  55.       fprintf (stderr, "error in matching fontname: %s\n", res);
  56.       fprintf (stderr, "Fontname `%s' ignored.\n", s);
  57.       return 0;
  58.     }
  59.  
  60.   if (re_exec("typewriter")
  61.       || re_exec("courier"))
  62.     font_id = 5;
  63.   else if (re_exec("modern"))
  64.     font_id = 4;
  65.   else if (re_exec("italic")
  66.        || re_exec("oblique"))
  67.     font_id = 3;
  68.   else if (re_exec("bold"))
  69.     font_id = 2;
  70.   else if (re_exec("times")
  71.       || re_exec("roman"))
  72.     font_id = 2;
  73.   else
  74.     fprintf (stderr, "Unrecognized font name `%s' ignored.\n", s);
  75.  
  76.   return 0;
  77. }
  78.  
  79.